d-i debian-installer/locale string en_US.UTF-8

d-i debian-installer/splash boolean false

d-i console-setup/ask_detect        boolean false
d-i console-setup/layoutcode        string us
d-i console-setup/variantcode       string

# !!!! do not use netcfg/enable option because netcfg segfaults
# d-i netcfg/enable boolean false
d-i netcfg/choose_interface select auto

# by default we use dhcp but it is possible to set network
# configuration via kernel parameters
d-i netcfg/dhcp_timeout string 30
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually

# these lines must be added via system kopts
# d-i netcfg/get_hostname string nailgun
# d-i netcfg/get_domain string example.com

d-i hw-detect/load_firmware boolean true

d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean false
d-i time/zone string <%= @ks_system_timezone %>

$SNIPPET('ubuntu_network_console_and_syslog')
$SNIPPET('ubuntu_partition')

#set fuel_version=$getVar('fuel_version', '')
#if $fuel_version >= '6.0'
d-i base-installer/kernel/image string linux-image-generic-lts-trusty
#else
d-i base-installer/kernel/image string linux-image-3.11
#end if


##########
# REPOS
##########

#import json
#set $repo_setup = json.loads($getVar("repo_setup"))
#set $repos = $repo_setup["repos"]
#set $base_mirror = $repos[0]
#set $base_mirror_protocol = $base_mirror["uri"].split(":", 1)[0]
#set $base_mirror_host = $base_mirror["uri"].split("http://")[1].split("/")[0]
#set $base_mirror_directory = "/" + $base_mirror["uri"].split("http://")[1].split("/", 1)[1]
#set $base_mirror_suite = $base_mirror["suite"]
#set $base_mirror_components = ", ".join($base_mirror["section"].split())
d-i mirror/protocol string $base_mirror_protocol
d-i mirror/country string manual
d-i mirror/http/hostname string $base_mirror_host
d-i mirror/http/directory string $base_mirror_directory
d-i mirror/http/proxy string
d-i mirror/suite string $base_mirror_suite
# Suite to use for loading installer components (optional).
d-i mirror/udeb/suite string $base_mirror_suite
# Components to use for loading installer components (optional).
d-i mirror/udeb/components multiselect $base_mirror_components
# Retry failed repo
d-i apt-setup/mirror/error select Retry

# Use network mirror
d-i apt-setup/use_mirror boolean true

# Select architecture to amd64. That's very important to dpkg, since
# by default we have both amd64 and i386.
d-i apt-setup/multiarch string amd64

# You can choose to install restricted and universe software, or to install
# software from the backports repository.
d-i apt-setup/restricted boolean false
d-i apt-setup/universe boolean false
d-i apt-setup/backports boolean false

# Select which update services to use; define the mirrors to be used.
# Values shown below are the normal defaults.
# d-i apt-setup/services-select multiselect
d-i apt-setup/security_host string 127.0.0.1
# d-i apt-setup/security_path string /ubuntu

d-i debian-installer/allow_unauthenticated boolean true

d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/modelcode string SKIP

# NOTE(kozhukalov): We avoid defining multiple mirrors
# using apt-setup/localN debconf variables.
# The reason for this is that it does not suport pinning.
# We define multiple repos with their priorities inside target
# and then use in-target apt-get to install additional packages.
# See ubuntu_repos_late and ubuntu_packages_late snippets.

##########
# USERS
##########

# Allow root login
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password <%= @ks_encrypted_root_password %>

d-i passwd/make-user boolean false

############
# PACKAGES
############

tasksel tasksel/first multiselect standard
debconf debconf/frontend select Noninteractive

# NOTE(kozhukalov): We deliberately avoid using
# pkgsel/include mechanism for installing additional packages.
# We need preferences for our additional mirrors
# and it is only possible if we put preferences into target and
# install packages using apt-get inside this target directory.
# See ubuntu_repos_late and ubuntu_packages_late snippets.

d-i pkgsel/language-packs multiselect en
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select none
d-i pkgsel/updatedb boolean true

d-i finish-install/keep-consoles    boolean false
d-i finish-install/reboot_in_progress       note

d-i cdrom-detect/eject boolean true

d-i debian-installer/exit/halt boolean false
d-i debian-installer/exit/poweroff boolean false


################
# LATE COMMANDS
################
# TODO:
# add puppet and mcollective configuration
# add network configuration
d-i preseed/late_command string true && \
$SNIPPET('ubuntu_repos_late')
echo 'APT::Get::AllowUnauthenticated 1;' > /target/etc/apt/apt.conf.d/02mirantis-allow-unsigned && \
#if $enableipv6 == False
echo 'precedence ::ffff:0:0/96 100' >> /target/etc/gai.conf && \
#end if
in-target apt-get update; \
in-target apt-get upgrade -y; \
#if $fuel_version >= '6.0'
in-target apt-get -y install linux-image-generic-lts-trusty linux-headers-generic-lts-trusty; \
#else
in-target apt-get -y install linux-image-3.11 linux-headers-3.11; \
#end if
#if $fuel_version >= '6.1'
$SNIPPET('ubuntu_trusty_packages_late')
#else
$SNIPPET('ubuntu_precise_packages_late')
#end if
$SNIPPET('ubuntu_partition_late')
$SNIPPET('ubuntu_disable_pxe') && \
$SNIPPET('ubuntu_network') && \
##FIXME Ubuntu 14.04 55netcfg-copy-config always cp /etc/network/interfaces /target/etc/network/interfaces
cp /target/etc/network/interfaces /etc/network/interfaces && \
$SNIPPET('cinder_create_lvm_group__ubuntu') && \
$SNIPPET('ubuntu_puppet_config') && \
$SNIPPET('ubuntu_mcollective_config') && \
$SNIPPET('ntp_to_masternode_ubuntu')
echo "nf_conntrack_ipv4" >> /target/etc/modules && \
echo "nf_conntrack_ipv6" >> /target/etc/modules && \
echo "net.nf_conntrack_max=1048576" >> /target/etc/sysctl.conf && \
mkdir -p /target/etc/nailgun-agent && \
#set nailgun_agent_conf = '/target/etc/nailgun-agent/config.yaml'
echo "---" > $nailgun_agent_conf && \
echo "url: '<%= scope.lookupvar('nailgun::cobbler::nailgun_api_url') %>'" >> $nailgun_agent_conf && \
echo target > /target/etc/nailgun_systemtype && \
$SNIPPET('ubuntu_authorized_keys')
sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" -e "s/.*PasswordAuthentication\ .*/PasswordAuthentication\ no/g" -e "/UseDNS/d" /target/etc/ssh/sshd_config && \
echo "UseDNS no" >> /target/etc/ssh/sshd_config && \
$SNIPPET('ubuntu_blacklist_i2c_piix4')
$SNIPPET('ubuntu_static_net')
$SNIPPET('ofed_install_with_sriov')
# Rsyslogd should send all messages to master node
$SNIPPET('target_logs_to_master_ubuntu')
$SNIPPET('ubuntu_remove_repos_late')
true

